﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WXWeb
{
    public partial class Login : BasePage
    {
        Access access = new Access();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                string uid = userid.Value;
                string pwd = password.Value;

                DataSet ds = access.Veiry(uid, pwd);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    Model.UserInfo user = new Model.UserInfo();
                    DataRow dr = ds.Tables[0].Rows[0];
                    user.ID = Convert.ToInt32(dr["id"]);
                    user.UserName = dr["userName"].ToString();
                    user.UID = dr["uid"].ToString();
                    user.PWD = dr["pwd"].ToString();
                    user.Sex = dr["sex"].ToString();
                    user.CreateTime = Convert.ToDateTime(dr["createTime"]);
                    user.UpdateTime = Convert.ToDateTime(dr["UpdateTime"]);
                    user.Skin = dr["skin"].ToString();
                    user.MID = int.Parse(dr["mid"].ToString());
                    user.Name = dr["name"].ToString();
                    Session["UserInfo"] = user;
                    Response.Redirect("Index.aspx");
                }
                else
                    AlertMessage("用户名或密码错误");
                
                //context.Response.End();
            }
            catch (Exception ex)
            {
               
                //context.Response.End();
            }
        }
    }
}